const app = getApp();
const Controller = require('../controllers/controllers.js').controller;
Page({
  data: {
    order: [1,2,3,4,5],
    page:1,
    pageSize:10,
    isEnd:false,
    tabindex:1,
  },
  
  onLoad: function (option) {
    
    if(option.index){
      this.setData({
        tabindex:option.index
      })
      
    }

  },
  onShow(){
    
  },
  tab(e){
    var index=e.currentTarget.dataset.index;
    this.setData({
      tabindex:index,
      order: [],
      page:1,
      pageSize:10,
      isEnd:false,
    })
    // this.clientOrderList()
  },
  clientOrderList(){
    var data={
      // saleType:2,
      orderStatus:this.data.tabindex==0?101:this.data.tabindex==1?0:this.data.tabindex==2?1:-100,
      page:this.data.page,
      pageSize:this.data.pageSize
    }
    Controller.clientOrderList(data).then(res=>{
      if(res.data.baseData && res.data.baseData.list.length>0){
        this.setData({
          order:this.data.order.concat(res.data.baseData.list),
        })
        
        if(res.data.baseData.lastPage){
          this.setData({
            isEnd:res.data.baseData.lastPage
          })
        }
      }else{
        this.setData({
          isEnd:true
        })
      }
    })
  },
  clientOrderCountList(){
    Controller.clientOrderCountList().then(res=>{
      if(res.data.baseData){
        this.setData({
          clientOrderCount:res.data.baseData,
        })
      }
    })
  },
  updateOrderNotice(){
    Controller.updateOrderNotice({type:1}).then(res=>{
      
    })
  },
  onReachBottom(){
    if(this.data.isEnd){
      return
    }else{
      this.setData({
        page:this.data.page+1
      })
      this.clientOrderList()
    }
    
  },
  
  report(e){
    var ordernum=e.currentTarget.dataset.ordernum;
    wx.navigateTo({
      url: '/pages/product/report',
    })
  },
  look(e){
    var ordernum=e.currentTarget.dataset.ordernum;
    wx.navigateTo({
      url: '/pages/product/report',
    })
  },
  comfirm(e){
    wx.showModal({
      title: '提示',
      content: '确认收货？',
      confirmColor:"#0A0A17",
      cancelColor:"#5E94E8",
      success (res) {
        if (res.confirm) {
          console.log('用户点击确定')
        }
      }
    })
    
  },


})